<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    /*诊疗项目补全*/
    autoCompleteClinic("itemName");
    function autoCompleteClinic(inputId) {
        var url = "${ctx}/oper/clinicItemDict/automatic?itemClass=E,J,K,F,G,Z";
        autoComplete(inputId, url,
                function (data) {
                    var rows = [];
                    for (var i = 0; i < data.length; i++) {
                        rows[rows.length] = {
                            data: data[i],
                            value: data[i].id,
                            result: data[i].itemName
                        };
                    }
                    return rows;
                }, function (data, i, max) {
                    return data.itemName + "|   " + data.itemCode + "|   " + data.price+"元";
                }, function (event, data, formatted) {
                    $("#clinicItemId").val(data.id);
                    $("#itemCode").val(data.itemCode);
                    $("#price").attr("value",data.price);
                    $("#sumPrice").attr("value",data.price);
                    $("#num").attr("value",1);
                    $("#itemClass").val(data.itemCalss);
                })
    }
    $(function(){
        $("#btnCancel").on('click',function(){
            hideShowTableTd('contentTable','0,1,2,3,4,5,6','1');
            $("#RightDiv").attr("style","display: none");
            $("#LeftDiv").attr("class","main-content col-lg-12");
            $("#LeftDiv").show('normal');
        })
        //改变总价
        $("#num").change(function(){
            var num=$(this).val();
            var price=$("#price").val();
            $("#sumPrice").val(num*price);
        })
        $("#btnSubmit").on('click',function(){
            formSaveLoad("rigthDoctorCenterDiv","inputForm","${ctx}/doctor/outpTreatRec/save","${ctx}/doctor/outpTreatRec/index?patientId="+$('#patientId').val()+"&clinicId="+$('#clinicId').val());
//            document.getElementById("inputForm").reset();
        })
    })
</script>
<div class="content-wrap">
    <div class="wrapper">
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="col-lg-12">
                    <form:form id="inputForm" data-parsley-validate=""  modelAttribute="outpTreatRec"  method="post" class="form-horizontal">
                        <form:hidden path="patientId" />
                        <form:hidden path="clinicId" />
                        <form:hidden path="itemClass" />
                        <form:hidden path="clinicItemId" />
                         <div class="form-group">
                            <label class="col-sm-4 control-label">项目名称：</label>
                            <div class="col-sm-8">
                                <form:input path="itemName" htmlEscape="false" class="form-control"  data-parsley-required="true"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">项目编码：</label>
                            <div class="col-sm-8">
                                 <form:input path="" disabled="true" id="itemCode" htmlEscape="false" class="form-control"  maxlength="64"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">数量：</label>
                            <div class="col-sm-8">
                                <div class="spinner input-group mb15">
                                    <input type="number" min="0" class="form-control input-sm spinner-input" name="num" id="num" placeholder="数量" value="" data-parsley-required="true">
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">执行科室：</label>
                            <div class="col-sm-8">
                                <sys:treeselect selectedParent="true"
                                                id="implementDept" update="false" isnull="true"
                                                name="implementDept" value="${orgDept.id}"
                                                labelName="${orgDept.deptName}" labelValue="${orgDept.deptName}" title="科室"
                                                url="/sys/orgDept/treeData"  cssClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">总价：</label>
                            <div class="col-sm-8">
                                <form:input path="sumPrice"  disabled="true" id="sumPrice" htmlEscape="false" class="form-control"  maxlength="20" />
                            </div>
                        </div>
                 </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input id="btnSubmit" class="btn btn-primary" type="button" value="保存">&nbsp;
                        <input id="btnCancel" class="btn" type="button" value="关 闭" ></div>
                </div>
                </form:form>
                <input type="hidden" id="price" value="">
            </div>
        </section>
    </div>
</div>

